/**
 * 
 */
package q4;

import java.util.Random;
import java.util.Scanner;

/**
 * @author 11611601 何海彬
 * @date Mar 28, 2017 8:16:15 AM
 */
public class GuessingNumber {
	private int magicNum;

	public GuessingNumber() {
		Random random = new Random();
		this.magicNum = random.nextInt(10);
	}

	public void guess() {
		int userNum;

		System.out.println("Welcome and guess a integer between 0 to 10.");
		Scanner input = new Scanner(System.in);
		userNum = input.nextInt();

		while (this.magicNum != userNum) {
			System.out.println("Please try again, input another integer between 0 to 10.");
			userNum = input.nextInt();
		}

		System.out.println("Congratulations!");

		input.close();
	}
}
